From b9dddc22b1ce386837e5003ff78a6daa75001625 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 31 Dec 2014 12:02:18 -0800 Subject: [PATCH] Update usage of git2-rs --- Cargo.lock | 9 +++++++++ Cargo.toml | 6 ++++++ src/cargo/lib.rs | 3 +-- src/cargo/sources/git/utils.rs | 11 ++++++----- src/rustversion.txt | 2 +- src/snapshots.txt | 8 ++++++++ tests/test_cargo_test.rs | 10 ++++++---- 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2763ca0c..6e294eb3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,6 +13,7 @@ dependencies = [ "rustc-serialize 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -178,6 +179,14 @@ name = "tar" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "term" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index 9d9fe8d04..922b32b66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,11 @@ authors = ["Yehuda Katz ", "Carl Lerche ", "Alex Crichton "] +[profile.test] +debug = false +[profile.dev] +debug = false + [lib] name = "cargo" path = "src/cargo/lib.rs" @@ -22,6 +27,7 @@ log = "0.1.0" docopt = "0.6.19" url = "0.2.7" rustc-serialize = "0.1.5" +term = "0.1" [dev-dependencies.hamcrest] git = "https://github.com/carllerche/hamcrest-rust.git" diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index a2baf0722..9a6768500 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -1,8 +1,7 @@ #![crate_name="cargo"] #![crate_type="rlib"] -#![feature(macro_rules, phase)] -#![feature(default_type_params)] +#![feature(macro_rules, phase, default_type_params, unboxed_closures)] #![deny(unused)] #![cfg_attr(test, deny(warnings))] diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 2389b6d62..33a0e06ba 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -343,7 +343,7 @@ impl<'a> GitCheckout<'a> { fn with_authentication(url: &str, cfg: &git2::Config, - f: |git2::Credentials| -> CargoResult) + f: |&mut git2::Credentials| -> CargoResult) -> CargoResult { // Prepare the authentication callbacks. // @@ -365,7 +365,7 @@ fn with_authentication(url: &str, let mut cred_helper = git2::CredentialHelper::new(url); cred_helper.config(cfg); let mut cred_error = false; - let ret = f(|url, username, allowed| { + let ret = f(&mut |&mut: url, username, allowed| { let creds = if allowed.contains(git2::SSH_KEY) { let user = username.map(|s| s.to_string()) .or_else(|| cred_helper.username.clone()) @@ -395,9 +395,10 @@ pub fn fetch(repo: &git2::Repository, url: &str, // Create a local anonymous remote in the repository to fetch the url with_authentication(url, &try!(repo.config()), |f| { - let mut cb = git2::RemoteCallbacks::new() - .credentials(f); - let mut remote = try!(repo.remote_anonymous(url.as_slice(), refspec)); + let mut cb = git2::RemoteCallbacks::new(); + cb.credentials(|a, b, c| f.call_mut((a, b, c))); + let mut remote = try!(repo.remote_anonymous(url.as_slice(), + Some(refspec))); try!(remote.add_fetch("refs/tags/*:refs/tags/*")); remote.set_callbacks(&mut cb); try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None, None)); diff --git a/src/rustversion.txt b/src/rustversion.txt index 42d1f76e6..8cbc9fc6e 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2014-12-29 +2014-12-30 diff --git a/src/snapshots.txt b/src/snapshots.txt index f08e9d6ae..29ab02253 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +2014-12-30 + linux-i386 ab8bba0918d3d2ddbd7fd21f147e223dbf04cece + linux-x86_64 0efe0f7bcbcbeb5494affcc8a2207db448a08c45 + macos-i386 e5097005b0a27c186b8edee24982fd4c3ebba81e + macos-x86_64 6c0bb776e5645fb93b67341b111c715f39b25511 + winnt-i386 2088c5256445b5bb2da57a71f6a9671e5a280477 + winnt-x86_64 950e25bcedc5ba9d96891523c9967f81d5f6c74d + 2014-12-21 linux-i386 4dea04e278192c5409f43794a98f20a8f59df2d9 linux-x86_64 3e48c573d3c4d26591feb7bfe988174720f08374 diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index dcab4a4a5..e41f04da6 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -268,9 +268,10 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured {doctest} bar -running 0 tests +running 1 test +test bar_0 ... ok -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING, @@ -567,9 +568,10 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured {doctest} syntax -running 0 tests +running 1 test +test foo_0 ... ok -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING, -- 2.30.2